package com.foreknow.service.impl;

import com.foreknow.bean.User;
import com.foreknow.dao.UserDao;
import com.foreknow.dao.impl.UserDaoImpl;
import com.foreknow.service.UserService;

import java.sql.SQLException;

public class UserServiceImpl implements UserService {
    private  UserDao userDao;

    //    public UserServiceImpl() {
    //        userDao  = new UserDaoImpl();
    //    }

    public UserDao getUserDao() {
        return userDao;
    }

    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }


    @Override
    public boolean save(User user) {
        boolean isRight = false;
        //调用持久层的方法
        try {
            isRight = userDao.addUser(user);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return isRight;
    }
}
